#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

void test1() {
  string s  = "hello";
  //string s2 = "杭州西湖边";
  // 转换成char*
  const char* str_char = s.c_str();
  printf("%s, 转换成char*, str_char:%s\n", __func__, str_char);
  // 长度
  int string_size = s.size();
  int string_length = s.length();
  cout<<"size="<<string_size<<", length="<<string_length<<endl;
  // 根据index获取char字符
  char cin2 = s.at(2);
  cout<<"cin2="<<cin2<<endl;
  // 遍历
  for(int i = 0; i < s.size(); i++) {
    cout<<"string["<<i<<"] = "<<s.at(i)<<endl;
  }
}

void test2(){
  string s1 = "abc";
  string s2("world");

  string s3 = s1 + s2;
  cout<<"串接，s3 = "<<s3<<endl;
  string s4(s3, s1.size());
  cout<<"s4="<<s4<<endl;
  cout<<"(s2 == s4)? = "<<(s2 == s4)<<endl;
  cout<<"(s2 == s1)? = "<<(s2 == s1)<<endl;
  cout<<"(s2 == s4) == true ?="<<((s2 == s4) == true)<<endl;
}
int main() {
  //test1();
  test2();
  return 0;
}
